

<!DOCTYPE html>
<html lang="zh_CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/fx-blog/img/ChenCat.png">
  <link rel="icon" href="/fx-blog/img/ChenCat.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Ray_Hughes">
  <meta name="keywords" content="">
  
    <meta name="description" content="SX-Item前言经历了 三四年的迭代 (2018~至今) 从 最初的 SX-Attribute2.0 迭代到 SX-Attribute 3.0现在将SX-Attribute3.0的物品功能分离出来（重写）  易用性 快捷性 自定义性 多关联 稳健性   SX-Attribute用户请不要直接迁移物品库到SX-Item两者之间拥有细微的差别   注：开发者均为专业开发者从事或学习软件行业  说用说">
<meta property="og:type" content="article">
<meta property="og:title" content="SX-Item - 专注于随机的物品管理系统">
<meta property="og:url" content="https://ray_hughes.gitee.io/fx-blog/2023/08/24/SX-Item/index.html">
<meta property="og:site_name" content="枫溪的山谷">
<meta property="og:description" content="SX-Item前言经历了 三四年的迭代 (2018~至今) 从 最初的 SX-Attribute2.0 迭代到 SX-Attribute 3.0现在将SX-Attribute3.0的物品功能分离出来（重写）  易用性 快捷性 自定义性 多关联 稳健性   SX-Attribute用户请不要直接迁移物品库到SX-Item两者之间拥有细微的差别   注：开发者均为专业开发者从事或学习软件行业  说用说">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-08-24T04:54:47.000Z">
<meta property="article:modified_time" content="2023-11-04T08:51:18.502Z">
<meta property="article:author" content="Ray_Hughes">
<meta name="twitter:card" content="summary_large_image">
  
  
  
  <title>SX-Item - 专注于随机的物品管理系统 - 枫溪的山谷</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/fx-blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/fx-blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/fx-blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"ray_hughes.gitee.io","root":"/fx-blog/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":60,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/fx-blog/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/fx-blog/js/utils.js" ></script>
  <script  src="/fx-blog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 7.0.0-rc2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/fx-blog/">
      <strong>枫溪的山谷</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/">
                <i class="iconfont icon-home-fill"></i>
                <span>主页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/categories/%E5%BC%80%E5%8F%91/">
                <i class="iconfont icon-code"></i>
                <span>开发心得</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/categories/%E6%8F%92%E4%BB%B6/">
                <i class="iconfont icon-th-large"></i>
                <span>插件</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" target="_blank" rel="noopener" href="http://maplefx.top:6520/fastsave">
                <i class="iconfont icon-plan"></i>
                <span>资源站</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/fx-blog/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('https://s1.ax1x.com/2023/09/05/pPrb1ot.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="SX-Item - 专注于随机的物品管理系统"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-08-23 20:54" pubdate>
          2023年8月23日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          7.4k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          63 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">SX-Item - 专注于随机的物品管理系统</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="SX-Item"><a href="#SX-Item" class="headerlink" title="SX-Item"></a>SX-Item</h1><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>经历了 三四年的迭代 <em>(2018~至今)</em> 从 最初的 SX-Attribute2.0 迭代到 SX-Attribute 3.0<br>现在将SX-Attribute3.0的物品功能分离出来（重写）</p>
<ol>
<li>易用性</li>
<li>快捷性</li>
<li>自定义性</li>
<li>多关联</li>
<li>稳健性</li>
</ol>
<blockquote>
<p>SX-Attribute用户请不要直接迁移物品库到SX-Item<br>两者之间拥有细微的差别</p>
</blockquote>
<blockquote>
<p>注：开发者均为专业开发者从事或学习软件行业</p>
</blockquote>
<h2 id="说用说明"><a href="#说用说明" class="headerlink" title="说用说明"></a>说用说明</h2><h3 id="基础用法"><a href="#基础用法" class="headerlink" title="基础用法"></a>基础用法</h3><p>细节都在默认生成的配置文件中有体现</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">Default-1:</span><br>  <span class="hljs-attr">Name:</span> <span class="hljs-string">&lt;s:DefaultPrefix&gt;&amp;c炎之洗礼&lt;s:DefaultSuffix&gt;</span> <span class="hljs-string">&lt;s:&lt;l:品质&gt;Color&gt;&lt;l:品质&gt;</span><br>  <span class="hljs-attr">ID:</span> <span class="hljs-string">&lt;l:&lt;l:职业&gt;ID&gt;</span><br>  <span class="hljs-attr">Lore:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;6品质等级: &lt;s:&lt;l:品质&gt;Color&gt;&lt;l:品质&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;b:&lt;l:品质&gt;:优秀:史诗&gt;&amp;6限制职业: &lt;l:职业&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;6物品类型: 主武器&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;6限制等级: &lt;c:int 10 * &lt;s:&lt;l:品质&gt;基数&gt;&gt;级&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;c攻击力: +&lt;l:攻击力&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;l:攻一-10&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;l:攻二-10&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;l:攻三-10&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;l:材质&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;s:&lt;l:品质&gt;宝石孔&gt;&#x27;</span><br>    <span class="hljs-comment">#   - &#x27;&amp;7耐久度: &lt;c:int &lt;r:300_350&gt; * &lt;s:&lt;l:品质&gt;基数&gt;&gt;/&lt;c:int 400 * &lt;s:&lt;l:品质&gt;基数&gt;&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;7耐久度: &lt;c:int &lt;d:0.6_0.9&gt; * &lt;l:耐久度&gt;&gt;/&lt;l:耐久度&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;b:&lt;l:品质&gt;:史诗&gt;&amp;c已绑定&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;a到期时间: &lt;t:10m&gt;&#x27;</span><br>    <span class="hljs-comment">#   - &#x27;&amp;a到期时间: &lt;t:600&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;b:&lt;l:品质&gt;:优秀:史诗&gt;                                    &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&lt;b:&lt;l:品质&gt;:优秀:史诗&gt;&lt;s:DefaultLore&gt;&#x27;</span><br>  <span class="hljs-attr">EnchantList:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&lt;s:&lt;l:职业&gt;附魔&gt;</span><br>  <span class="hljs-attr">ClearAttribute:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">Random:</span><br>    <span class="hljs-string">攻击力:</span> <span class="hljs-string">&lt;c:20</span> <span class="hljs-string">*</span> <span class="hljs-string">&lt;s:&lt;l:品质&gt;基数&gt;&gt;</span><br>    <span class="hljs-string">耐久度:</span> <span class="hljs-string">&lt;c:int</span> <span class="hljs-string">&lt;r:350_400&gt;</span> <span class="hljs-string">*</span> <span class="hljs-string">&lt;s:&lt;l:品质&gt;基数&gt;&gt;</span><br>  <span class="hljs-attr">NBT:</span><br>    <span class="hljs-attr">arg1.arg2:</span> <span class="hljs-string">测试NBT</span><br>    <span class="hljs-attr">sx:</span><br>    <span class="hljs-attr">attribute:</span><br>      <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;词条一&#x27;</span><br>      <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;词条二&#x27;</span><br>      <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;词条三&#x27;</span><br>      <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;SX-Attribute预留属性接口&#x27;</span><br>      <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;如需使用随机则需学习高等随机&#x27;</span><br>  <span class="hljs-attr">ProtectNBT:</span> <span class="hljs-comment">#保护附魔NBT不被更新</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&quot;Enchantments&quot;</span><br></code></pre></td></tr></table></figure>

<h3 id="随机节点"><a href="#随机节点" class="headerlink" title="随机节点"></a>随机节点</h3><p>形如 <a href="key:value">key:value</a> 格式</p>
<p>key是结构的类型</p>
<p>value是参与结构运行的内容</p>
<p>例如 &lt;d:0.6_0.9&gt; 实际上就是个小数随机 0.6~0.9之间的数 抽取一个</p>
<p>结构汇总：</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>Key</th>
<th>例子</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>整行判断</td>
<td>b</td>
<td>&lt;b:匹配名:匹配词1:匹配词2:匹配词3:匹配词4&gt;</td>
<td></td>
</tr>
<tr>
<td>时间格式</td>
<td>t</td>
<td>&lt;t:1Y1M1D1h1m1s&gt;</td>
<td></td>
</tr>
<tr>
<td>计算器</td>
<td>c</td>
<td>&lt;c:+6+&gt; 或 &lt;c:int 7+7.5&gt;</td>
<td>使用压栈计算器实现</td>
</tr>
<tr>
<td>锁定随机</td>
<td>l</td>
<td>&lt;l:某个随机组&gt;</td>
<td>使用l:后同步此值</td>
</tr>
<tr>
<td>一般随机</td>
<td>s</td>
<td>&lt;s:某个随机组&gt;</td>
<td>使用s: 每次重新获取</td>
</tr>
<tr>
<td>小数随机</td>
<td>d</td>
<td>&lt;d:0.6_0.9&gt;</td>
<td></td>
</tr>
<tr>
<td>整数随机</td>
<td>i</td>
<td>&lt;i:1_25565&gt;</td>
<td></td>
</tr>
<tr>
<td>脚本随机</td>
<td>j</td>
<td>&lt;j:script.eval#&lt;l:品质&gt;,&lt;d:0.5_1.0&gt;&gt;</td>
<td>&lt;j:文件名.方法名#参数&gt;</td>
</tr>
<tr>
<td>UUID随机</td>
<td>u</td>
<td>&lt;u:random&gt; 或 &lt;u:文字&gt;</td>
<td>生成一个完全随机的UUI或者根据字符串生成UUID</td>
</tr>
</tbody></table>
<blockquote>
<p>注：如果在高版本使用 JS 需要使用 momojs 这种拓展库</p>
</blockquote>
<h3 id="随机组"><a href="#随机组" class="headerlink" title="随机组"></a>随机组</h3><h4 id="权重与概率"><a href="#权重与概率" class="headerlink" title="权重与概率"></a>权重与概率</h4><p>传统SX2.0写法:</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">品质:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">&quot;普通&quot;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">&quot;普通&quot;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">&quot;优秀&quot;</span><br></code></pre></td></tr></table></figure>

<p>SXItem写法:</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">品质:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-attr">2:</span> <span class="hljs-string">&quot;普通&quot;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-attr">1:</span> <span class="hljs-string">&quot;优秀&quot;</span><br></code></pre></td></tr></table></figure>

<p>前面的数字 就是本条的权重</p>
<p>也可以使用js的形式</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">function</span> <span class="hljs-title function_">drawResult</span>(<span class="hljs-params">docker, args</span>) &#123;<br>    <span class="hljs-keyword">const</span> result = <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() &lt; <span class="hljs-number">0.333</span> ? <span class="hljs-string">&#x27;优秀&#x27;</span> : <span class="hljs-string">&#x27;普通&#x27;</span>;<br>    <span class="hljs-keyword">return</span> result;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>&lt;j:script.drawResult&gt;</p>
<h4 id="多行随机"><a href="#多行随机" class="headerlink" title="多行随机"></a>多行随机</h4><p>通常你可以这样写</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">射手附魔:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-bullet">-</span> <span class="hljs-string">ARROW_DAMAGE:&lt;r:0_2&gt;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">ARROW_INFINITE:&lt;r:0_1&gt;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-bullet">-</span> <span class="hljs-string">ARROW_DAMAGE:&lt;r:0_2&gt;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">ARROW_FIRE:&lt;r:0_2&gt;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-bullet">-</span> <span class="hljs-string">ARROW_DAMAGE:&lt;r:0_2&gt;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">DURABILITY:&lt;r:0_1&gt;</span><br></code></pre></td></tr></table></figure>

<p>当然你也可以用 js</p>
<p>注意：因为脚本引擎限制 无法使用 [] 创建数组 请使用 Utils.mutableList();</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">function</span> <span class="hljs-title function_">subAttribute</span>(<span class="hljs-params">docker, args</span>) &#123;<br>    <span class="hljs-keyword">var</span> amount = args[<span class="hljs-number">0</span>];<br>    <span class="hljs-keyword">var</span> level = <span class="hljs-built_in">parseInt</span>(args[<span class="hljs-number">1</span>]);<br>    <span class="hljs-keyword">var</span> mutab = <span class="hljs-built_in">parseFloat</span>(args[<span class="hljs-number">2</span>]);<br>    <span class="hljs-keyword">var</span> def = level * <span class="hljs-number">0.25</span> * mutab + <span class="hljs-number">5</span>;<br><br>    <span class="hljs-keyword">var</span> lore = <span class="hljs-title class_">Utils</span>.<span class="hljs-title function_">mutableList</span>();<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">1</span>; i &lt;= amount; i++) &#123;<br>        <span class="hljs-keyword">var</span> attr = docker.<span class="hljs-title function_">replace</span>(<span class="hljs-string">&quot;&lt;s:副属性&gt;&quot;</span>);<br>        <span class="hljs-keyword">var</span> value = <span class="hljs-title class_">Utils</span>.<span class="hljs-title function_">randomDouble</span>(def - level * <span class="hljs-number">0.5</span>, def + level * <span class="hljs-number">0.25</span>);<br>        <span class="hljs-keyword">if</span> (attr.<span class="hljs-title function_">indexOf</span>(<span class="hljs-string">&quot;率&quot;</span>) != -<span class="hljs-number">1</span>) &#123;<br>            lore.<span class="hljs-title function_">add</span>(<span class="hljs-string">&quot; &amp;7&quot;</span> + attr + <span class="hljs-string">&quot;:&amp;f &quot;</span> + value.<span class="hljs-title function_">toFixed</span>(<span class="hljs-number">2</span>) + <span class="hljs-string">&quot;%&quot;</span>);<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>            lore.<span class="hljs-title function_">add</span>(<span class="hljs-string">&quot; &amp;7&quot;</span> + attr + <span class="hljs-string">&quot;:&amp;f &quot;</span> + value.<span class="hljs-title function_">toFixed</span>(<span class="hljs-number">2</span>));<br>        &#125;<br>    &#125;<br>    <span class="hljs-keyword">return</span> lore;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="全局随机组与局部随机组"><a href="#全局随机组与局部随机组" class="headerlink" title="全局随机组与局部随机组"></a>全局随机组与局部随机组</h3><h4 id="全局随机组"><a href="#全局随机组" class="headerlink" title="全局随机组"></a>全局随机组</h4><p>指的是写在 RandomString 文件夹的随机组</p>
<p>可以在任意位置调用</p>
<h4 id="局部随机组"><a href="#局部随机组" class="headerlink" title="局部随机组"></a>局部随机组</h4><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">Lore:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;7覆盖全局变量结果-&gt; &lt;s:DefaultPrefix&gt;&#x27;</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;7全局和局部混合结果-&gt; &lt;s:DefaultLore&gt;&#x27;</span><br><span class="hljs-attr">Random:</span><br>  <span class="hljs-attr">DefaultPrefix:</span> <span class="hljs-string">&quot;Prefix&quot;</span><br>  <span class="hljs-attr">DefaultLore:</span><br>    <span class="hljs-comment"># 2/3的概率随机到Lore，1/3的概率随机到全局变量</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-attr">2:</span> <span class="hljs-string">&quot;Lore&quot;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-attr">1:</span> <span class="hljs-string">~</span><br></code></pre></td></tr></table></figure>

<p>优先级： 全局 &gt; 局部</p>
<p>所以 局部会覆盖全局的值</p>
<h3 id="MythicMob-Hook"><a href="#MythicMob-Hook" class="headerlink" title="MythicMob Hook"></a>MythicMob Hook</h3><h4 id="掉落"><a href="#掉落" class="headerlink" title="掉落"></a>掉落</h4><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">废弃村镇_蜘蛛女王:</span><br>  <span class="hljs-attr">Type:</span> <span class="hljs-string">SPIDER</span><br>  <span class="hljs-attr">Display:</span> <span class="hljs-string">&#x27;&amp;c蜘蛛女王&#x27;</span><br>  <span class="hljs-attr">Health:</span> <span class="hljs-number">200</span><br>  <span class="hljs-attr">Damage:</span> <span class="hljs-number">8</span><br>  <span class="hljs-attr">SX-Drop:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">材料_水元素</span> <span class="hljs-number">1</span><span class="hljs-number">-6</span> <span class="hljs-number">1</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">材料_蛛母复眼</span> <span class="hljs-number">1</span><span class="hljs-number">-2</span> <span class="hljs-number">1</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">货币_拾取_随机</span> <span class="hljs-number">1</span> <span class="hljs-number">1</span> <span class="hljs-string">F:1</span> <span class="hljs-string">T:10</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">阅历_拾取_随机</span> <span class="hljs-number">1</span> <span class="hljs-number">1</span> <span class="hljs-string">F:1</span> <span class="hljs-string">T:20</span><br>  <span class="hljs-attr">Options:</span><br>    <span class="hljs-attr">MovementSpeed:</span> <span class="hljs-number">0.3</span><br>    <span class="hljs-attr">PreventOtherDrops:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">Skills:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">skill&#123;s=蛛母_跃击&#125;</span> <span class="hljs-string">@target</span> <span class="hljs-string">~onTimer:150</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">skill&#123;s=蛛母_召唤&#125;</span> <span class="hljs-string">@Self</span> <span class="hljs-string">~onTimer:350</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">skill&#123;s=蛛母_召唤&#125;</span> <span class="hljs-string">@Self</span> <span class="hljs-string">~onSpawn</span><br></code></pre></td></tr></table></figure>

<p>SX-Drop</p>
<p>然后和mm自带的掉落一样 物品名 数量 概率</p>
<p>但是后续可以跟随自定义参数 变量名:变量值</p>
<p>上述的例子对应的物品如下</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">货币_拾取_随机:</span><br>  <span class="hljs-attr">Name:</span> <span class="hljs-string">&#x27;&amp;7货币&#x27;</span><br>  <span class="hljs-attr">ID:</span> <span class="hljs-string">&lt;j:Default.getMoneyType#&lt;l:Value&gt;&gt;</span><br>  <span class="hljs-attr">Lore:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;f &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;f  价值: &lt;l:Value&gt;&#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;6 &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;f  常用的货币  &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;f &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;7一曰 · 春风&#x27;</span><br>  <span class="hljs-attr">Update:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">Random:</span><br>    <span class="hljs-attr">F:</span> <span class="hljs-number">0</span><br>    <span class="hljs-attr">T:</span> <span class="hljs-number">0</span><br>    <span class="hljs-attr">Value:</span> <span class="hljs-string">&lt;d:&lt;l:F&gt;_&lt;l:T&gt;&gt;</span><br>  <span class="hljs-attr">NBT:</span><br>    <span class="hljs-attr">Money:</span><br>      <span class="hljs-attr">value:</span> <span class="hljs-string">&lt;l:Value&gt;</span><br></code></pre></td></tr></table></figure>

<h4 id="装备"><a href="#装备" class="headerlink" title="装备"></a>装备</h4><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">SX-Equipment:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">物品ID:位置</span> <span class="hljs-string">概率</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">物品ID:位置</span> <span class="hljs-string">概率</span> <span class="hljs-string">局部变量</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">物品ID:位置</span> <span class="hljs-string">概率</span> <span class="hljs-string">Key1:Value1</span> <span class="hljs-string">Key2:Value2</span><br></code></pre></td></tr></table></figure>

<h4 id="内置变量"><a href="#内置变量" class="headerlink" title="内置变量"></a>内置变量</h4><p>如果物品从怪物身上掉落下来 可以使用以下变量</p>
<table>
<thead>
<tr>
<th>变量名</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>mob_level</td>
<td>怪物等级</td>
</tr>
<tr>
<td>mob_name_display</td>
<td>怪物显示名字</td>
</tr>
<tr>
<td>mob_name_internal</td>
<td>怪物内部ID</td>
</tr>
<tr>
<td>mob_uuid</td>
<td>怪物UUID</td>
</tr>
</tbody></table>
<p>例如</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-string">货币_拾取_随机:</span><br>  <span class="hljs-attr">Name:</span> <span class="hljs-string">&#x27;&amp;7货币&#x27;</span><br>  <span class="hljs-attr">ID:</span> <span class="hljs-string">&lt;j:Default.getMoneyType#&lt;l:Value&gt;&gt;</span><br>  <span class="hljs-attr">Lore:</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;&amp;f &#x27;</span><br>    <span class="hljs-bullet">-</span> <span class="hljs-string">&#x27;来源: &lt;s:mob_name_display&gt;&#x27;</span><br></code></pre></td></tr></table></figure>

<p>这样就可以实现随机货币(物品)掉落了</p>
<h3 id="动作拓展"><a href="#动作拓展" class="headerlink" title="动作拓展"></a>动作拓展</h3><p>想用SX-Item做一些道具？<br>试试这个吧</p>
<p><a href="https://ray_hughes.gitee.io/fx-blog/2023/08/24/MythicItemStyrke">https://ray_hughes.gitee.io/fx-blog/2023/08/24/MythicItemStyrke</a></p>
<p>包含的内容:</p>
<ul>
<li>PAPI变量 显示玩家SXItem物品</li>
<li>快捷指令 给予 &#x2F; 扣除 玩家的 SXItem物品</li>
<li>对SXItem物品的一些动作拓展 监听动作</li>
<li>对龙核插件的槽位拓展兼容</li>
<li>对MythicMobsItem物品同样兼容以上功能</li>
</ul>
<h2 id="获取插件"><a href="#获取插件" class="headerlink" title="获取插件"></a>获取插件</h2><p><a target="_blank" rel="noopener" href="https://github.com/Saukiya/SX-Item/releases">https://github.com/Saukiya/SX-Item/releases</a></p>
<p>官方链接</p>
<h2 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h2><ul>
<li>SX-Item 会有 PickListsner 刷物品的BUG吗?<ul>
<li>不会, 请你在拓展插件中 在扣除物品环节之前 延迟1tick</li>
</ul>
</li>
<li>SX-Item 操作NBT会不会大量使用 Copy 占用内存?<ul>
<li>不会, 本插件使用了NBTWrapper用代理的方式操作NBT不产生冗余对象</li>
</ul>
</li>
<li>我想加载自己的配置文件自己管理!<ul>
<li>可以的 在ItemManager类中操作loadItem(组名,文件)</li>
<li>具体见下方API</li>
</ul>
</li>
</ul>
<h2 id="API速览"><a href="#API速览" class="headerlink" title="API速览"></a>API速览</h2><h3 id="ItemManager"><a href="#ItemManager" class="headerlink" title="ItemManager"></a>ItemManager</h3><h4 id="加载物品"><a href="#加载物品" class="headerlink" title="加载物品"></a>加载物品</h4><p>加载由你的配置文件传递的物品，通常我们可以把物品配置上传云端</p>
<p>例如自己的管理系统 或者是OSS镜像 来实现多服同步配置文件</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs java">    <span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 加载物品列表</span><br><span class="hljs-comment"> * 注意事项:</span><br><span class="hljs-comment"> * 1. 不可以覆盖其他group的key值</span><br><span class="hljs-comment"> * 2. 不会被SX重载时清除</span><br><span class="hljs-comment"> * 3. 每次加载清空上次的存储</span><br><span class="hljs-comment"> * 4. 覆盖会清空之前的值</span><br><span class="hljs-comment"> *</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> group     组名</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> directory 文件夹</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">loadItem</span><span class="hljs-params">(String group,File directory)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">loadItem</span><span class="hljs-params">(String group,ConfigurationSection...configs)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">loadItem</span><span class="hljs-params">(String group,Map&lt;String, ConfigurationSection&gt; configs)</span><br><br></code></pre></td></tr></table></figure>

<h4 id="获取一个物品"><a href="#获取一个物品" class="headerlink" title="获取一个物品"></a>获取一个物品</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 获取一个物品</span><br><span class="hljs-comment"> *</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> itemName  物品名</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> player 玩家</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> args 额外参数(局部变量) K,V,K,V 形式传递</span><br><span class="hljs-comment"> *</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">public</span> ItemStack <span class="hljs-title function_">getItem</span><span class="hljs-params">(String itemName,<span class="hljs-meta">@Nonnull</span> Player player,Object...args)</span><br><br><span class="hljs-comment">//用法:</span><br>        SXItem.getItemManager().getItem(<span class="hljs-string">&quot;item_name&quot;</span>,player,<span class="hljs-string">&quot;key&quot;</span>,<span class="hljs-string">&quot;value&quot;</span>)<br></code></pre></td></tr></table></figure>

<h4 id="存入物品"><a href="#存入物品" class="headerlink" title="存入物品"></a>存入物品</h4><p>分为 SXITEM 模式 (Default)</p>
<p>无损 Import 模式 (Import)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs java"><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 保存物品</span><br><span class="hljs-comment"> *</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> key  编号</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> item 物品</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> type 类型 Default / Import</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@return</span> boolean</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@throws</span> IOException IOException</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">public</span> <span class="hljs-type">boolean</span> <span class="hljs-title function_">saveItem</span><span class="hljs-params">(String key,ItemStack item,String type)</span><span class="hljs-keyword">throws</span> IOException<br><br></code></pre></td></tr></table></figure>

<h4 id="数字ID兼容"><a href="#数字ID兼容" class="headerlink" title="数字ID兼容"></a>数字ID兼容</h4><p>老东西们 这是适合1.7.10遗老的玩具<br>数字ID转换</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs java">    <span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 获取物品材质</span><br><span class="hljs-comment"> *</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> key 索引</span><br><span class="hljs-comment"> * <span class="hljs-doctag">@return</span> 材质</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Material <span class="hljs-title function_">getMaterial</span><span class="hljs-params">(String key)</span><br></code></pre></td></tr></table></figure>

<h3 id="Event"><a href="#Event" class="headerlink" title="Event"></a>Event</h3><h4 id="MM死亡后物品放入背包事件"><a href="#MM死亡后物品放入背包事件" class="headerlink" title="MM死亡后物品放入背包事件"></a>MM死亡后物品放入背包事件</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs java">SXItemMythicMobsGiveToInventoryEvent&#123;<br><br><span class="hljs-comment">// 物品抽象</span><br><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> IGenerator item;<br><br><span class="hljs-comment">// 获得物品的玩家</span><br><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> Player player;<br><br><span class="hljs-comment">// 怪物类型</span><br><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> String mobType;<br><br><span class="hljs-comment">// 物品实例</span><br><span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ItemStack itemStack;<br><br><span class="hljs-comment">// 是否取消</span><br><span class="hljs-keyword">private</span> <span class="hljs-type">boolean</span> cancelled;<br><br>        &#125;<br></code></pre></td></tr></table></figure>

<h4 id="插件重载事件"><a href="#插件重载事件" class="headerlink" title="插件重载事件"></a>插件重载事件</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs java">SXItemReloadEvent<br></code></pre></td></tr></table></figure>

<h4 id="物品更新与生成"><a href="#物品更新与生成" class="headerlink" title="物品更新与生成"></a>物品更新与生成</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs java">SXItemSpawnEvent<br>        SXItemUpdateEvent<br></code></pre></td></tr></table></figure>

<p>例子 兼容 ItemsAdder 来自拓展工具包</p>
<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><code class="hljs kotlin">    <span class="hljs-meta">@SubscribeEvent(priority = EventPriority.LOWEST)</span><br><span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">itemsAdder</span><span class="hljs-params">(event: <span class="hljs-type">SXItemSpawnEvent</span>)</span></span> &#123;<br>    <span class="hljs-keyword">val</span> items = event.ig.config?.getString(<span class="hljs-string">&quot;ItemsAdder&quot;</span>) ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> ia = CustomStack.getInstance(items)?.itemStack ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> customData = ia.itemMeta?.customModelData ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> item = event.item ?: <span class="hljs-keyword">return</span><br>    item.modifyMeta&lt;ItemMeta&gt; &#123;<br>        setCustomModelData(customData)<br>    &#125;<br>    <span class="hljs-keyword">val</span> old = item.itemMeta?.clone() ?: <span class="hljs-keyword">return</span><br>    item.type = ia.type<br>    item.itemMeta = old<br>&#125;<br><br><span class="hljs-meta">@SubscribeEvent(priority = EventPriority.LOWEST)</span><br><span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">itemsAdder</span><span class="hljs-params">(event: <span class="hljs-type">SXItemUpdateEvent</span>)</span></span> &#123;<br>    <span class="hljs-keyword">val</span> items = event.ig.config?.getString(<span class="hljs-string">&quot;ItemsAdder&quot;</span>) ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> ia = CustomStack.getInstance(items)?.itemStack ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> customData = ia.itemMeta?.customModelData ?: <span class="hljs-keyword">return</span><br>    <span class="hljs-keyword">val</span> item = event.item ?: <span class="hljs-keyword">return</span><br>    item.modifyMeta&lt;ItemMeta&gt; &#123;<br>        setCustomModelData(customData)<br>    &#125;<br>    <span class="hljs-keyword">val</span> old = item.itemMeta?.clone() ?: <span class="hljs-keyword">return</span><br>    item.type = ia.type<br>    item.itemMeta = old<br>&#125;<br></code></pre></td></tr></table></figure>

<p>不被保护的NBT是不会被继承的 通常为Lore MetaData</p>
<p>自定义NBT可以通过保护的手段来不被更新</p>
<p>但是原版的NBT 比如 Lore就要通过这种方式</p>
<p>或者是可以把lore放入NBT 然后Lore中进行<code>&lt;s&gt;</code>引用</p>
<p>也可以实现动态跟进</p>
<h3 id="PAPIHOOK"><a href="#PAPIHOOK" class="headerlink" title="PAPIHOOK"></a>PAPIHOOK</h3><figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs txt">%sxitem_r:6_7%<br></code></pre></td></tr></table></figure>


                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/fx-blog/categories/%E6%8F%92%E4%BB%B6/" class="category-chain-item">插件</a>
  
  
    <span>></span>
    
  <a href="/fx-blog/categories/%E6%8F%92%E4%BB%B6/%E5%85%8D%E8%B4%B9/" class="category-chain-item">免费</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>SX-Item - 专注于随机的物品管理系统</div>
      <div>https://ray_hughes.gitee.io/fx-blog/2023/08/24/SX-Item/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Ray_Hughes</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年8月23日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/fx-blog/2023/08/26/MacForJava/" title="MacForJava - 写给喵的入门手册">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">MacForJava - 写给喵的入门手册</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/fx-blog/2023/08/24/GuShiAPI/" title="GuShiAPI - 关于首页一言">
                        <span class="hidden-mobile">GuShiAPI - 关于首页一言</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="twikoo"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#comments', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/twikoo/1.6.8/twikoo.all.min.js', function() {
        var options = Object.assign(
          {"envId":"https://twikoo.bingzi.online","region":"ap-shanghai","path":"window.location.pathname"},
          {
            el: '#twikoo',
            path: 'window.location.pathname',
            onCommentLoaded: function() {
              Fluid.utils.listenDOMLoaded(function() {
                var imgSelector = '#twikoo .tk-content img:not(.tk-owo-emotion)';
                Fluid.plugins.imageCaption(imgSelector);
                Fluid.plugins.fancyBox(imgSelector);
              });
            }
          }
        )
        twikoo.init(options)
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/fx-blog/js/events.js" ></script>
<script  src="/fx-blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/fx-blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/fx-blog/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/fx-blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
